package com.demo1;

import java.math.BigDecimal;
import java.util.Date;
import java.util.StringJoiner;

public class ReturnIntArr {
    //1.设计一个方法，返回任意整形数组的内容

    public static void main(String[] args) {

        String sr=GetArrayData(new int[]{11,22,33});
        System.out.println(sr);

        //更高效StringJoiner
        StringJoiner sj=new StringJoiner(",","[","]");
        sj.add("1");
        sj.add("1");
        sj.add("1");
        System.out.println(sj);
        //统计时间
        long time=System.currentTimeMillis();
        System.out.println(time);
        //BigDecimal精确运算
        double a= 1.1;
        double b= 1.2;
        BigDecimal a1=BigDecimal.valueOf(a);
        BigDecimal b1=BigDecimal.valueOf(b);
        BigDecimal c1=a1.add(b1);
        System.out.println(c1);
        Date d=new Date();
        System.out.println(d);//当前时间
        long tim=d.getTime();
        System.out.println(tim);//时间毫秒值
        time+=2*1000;
        Date d2=new Date(tim);
        System.out.println(tim);


    }

    public static String GetArrayData(int[] arr){
        StringBuilder sb=new StringBuilder();
        sb.append("[");
        for (int i = 0; i < arr.length; i++) {
            if(i==arr.length-1){
                sb.append(arr[i]);
            }else {
                sb.append(arr[i]).append(",");
            }
        }
        sb.append("]");
        return  sb.toString();
    }


}
